# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=networkmanager-vpnc
pkgver=1.2.8
pkgrel=3
pkgdesc="NetworkManager VPN plugin for VPNC"
url="https://wiki.gnome.org/Projects/NetworkManager"
arch=(loong64 x86_64)
license=(GPL)
depends=(
  libnm
  libsecret
  vpnc
)
makedepends=(
  git
  intltool
  libnma
  libnma-gtk4
  python
)
optdepends=(
  'libnma-gtk4: GUI support (GTK 4)'
  'libnma: GUI support (GTK 3)'
)
_commit=75f664ff13ff1de9bf305894ccd94b30867bd06a  # tags/1.2.8^0
source=("git+https://gitlab.gnome.org/GNOME/NetworkManager-vpnc.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd NetworkManager-vpnc
  git describe --tags | sed 's/-dev/dev/;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd NetworkManager-vpnc

  # https://gitlab.gnome.org/GNOME/NetworkManager-vpnc/-/issues/8
  # https://gitlab.gnome.org/GNOME/NetworkManager-vpnc/-/merge_requests/9
  git cherry-pick -n f4df2db6ca1c0dfe29ea721c443f38c545721be9

  intltoolize --automake --copy
  autoreconf -fvi
}

build() {
  cd NetworkManager-vpnc
  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
    --libexecdir=/usr/lib --disable-static --with-gtk4
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd NetworkManager-vpnc
  make DESTDIR="$pkgdir" install dbusservicedir=/usr/share/dbus-1/system.d
}

# vim:set sw=2 sts=-1 et:
